package com.xbongbong.pro.message.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author youli.chen
 * @version v1.0
 * @description: 短信发送来源类型枚举
 * @date 2019/3/19 19:36
 * @since v1.0
 */
@Getter
public enum SmsSendFromTypeEnum {
    /**
     * 短信发送来源类型
     */
    SMS_SEND(XbbRefTypeEnum.SEND_MESSAGE.getCode(), 0, "enum.smsSendFromType.name.sms_send", "smsSend", 1, ""),

    SMS_SEND_FOR_BUSINESS(XbbRefTypeEnum.SEND_MESSAGE.getCode(), 1, "enum.smsSendFromType.name.sms_send_for_business", "smsSendForBusiness", 1, ""),

    SMS_RE_SEND(XbbRefTypeEnum.SEND_MESSAGE.getCode(), 2, "enum.smsSendFromType.name.sms_re_send", "smsReSend", 1, ""),


    /**
     * code 404
     */
    UNKNOWN(XbbRefTypeEnum.UNKNOWN.getCode(), 0, "enum.smsSendFromType.name.unknown", "unknown", 0, "");

    /** 枚举值 -- 推送类型标识*/
    private final int		code;

    /** 枚举值 -- 推送子类型标识*/
    private final int		subCode;

    /** 枚举信息--推送名称*/
    private final String    name;

    /** 枚举描述 --角色使用时状态*/
    private final String	alias;

    /** 枚举描述 --是否实时推送*/
    private final int	isRealTime;

    /** 枚举描述 --钉钉文档中的推送类型*/
    private final String	ddPushType;

    SmsSendFromTypeEnum(int code, int subCode, String name, String alias, int isRealTime, String ddPushType) {
        this.code = code;
        this.subCode = subCode;
        this.name = name;
        this.alias = alias;
        this.isRealTime = isRealTime;
        this.ddPushType = ddPushType;
    }

    /**
     * 通过枚举 code 获得枚举
     * @param code 枚举类型英文别名
     * @return SmsSendTypeEnum
     */
    public static SmsSendFromTypeEnum getByCode(Integer code) {
        for (SmsSendFromTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
